import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:moose_app/core/utils/navigate_util.dart';
import 'package:moose_app/ui/screens/welcome/welcome_screen.dart';
import 'package:moose_app/ui/values/colors.dart';
import 'package:moose_app/ui/values/constants.dart';
import 'package:moose_app/ui/widgets/pagination/custom_pagination.dart';

class ATHGuideScreen extends StatefulWidget {
  static final String routeName = "app://guide";

  @override
  _ATHGuideScreenState createState() => _ATHGuideScreenState();
}

class _ATHGuideScreenState extends State<ATHGuideScreen> {
  List<String> guideImages = [
    'assets/images/guide-1.jpg',
    'assets/images/guide-2.jpg',
  ];

  void _handleCheck() async {
    ATHNavigator.pushReplace(context, ATHWelcomeScreen.routeName,
        clearStack: true);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Swiper(
        itemCount: guideImages.length,
        itemBuilder: (BuildContext context, int position) {
          String imagePath = guideImages[position];
          return Stack(
            fit: StackFit.passthrough,
            alignment: Alignment.center,
            children: [
              Image.asset(imagePath, fit: BoxFit.cover),
              position == guideImages.length - 1
                  ? Positioned(
                      bottom: kSize100,
                      child: TextButton(
                        onPressed: () {
                          _handleCheck();
                        },
                        style: ButtonStyle(
                            padding: MaterialStateProperty.all(
                                EdgeInsets.symmetric(
                                    vertical: kSize16, horizontal: kSize32)),
                            backgroundColor:
                                MaterialStateProperty.all(kColorPrimary)),
                        child: Text(
                          "立即体验",
                          style: TextStyle(color: Colors.white),
                        ),
                      ),
                    )
                  : SizedBox()
            ],
          );
        },
        pagination: SwiperPagination(
            alignment: Alignment.bottomCenter,
            builder: CustomSwiperPaginationBuilder(
                color: kColorPrimaryLight, activeColor: kColorPrimary)),
        loop: false,
        scrollDirection: Axis.horizontal,
      ),
    );
  }
}
